<template>
    <div class="container">
        <div class="demo-input-size">
            <div class="conter">
                <p class="p1">车位位置：</p>
                <el-input
                    placeholder="请输入车位位置"
                    suffix-icon="el-icon-truck"
                    v-model="updata.address"
                >
                </el-input>
            </div>
            <div class="conter">
                <p class="p1">车位号：</p>
                <el-input
                    size="medium"
                    placeholder="请输入车位号"
                    suffix-icon="el-icon-truck"
                    v-model="updata.number"
                >
                </el-input>
            </div>
            <div class="conter">
                <p class="p1">产权信息：</p>
                <el-input
                    size="medium"
                    placeholder="请输入产权信息"
                    suffix-icon="el-icon-truck"
                    v-model="updata.property"
                >
                </el-input>
            </div>
            <div class="conter">
                <p class="p1">出租周期：</p>
                <el-input
                    size="medium"
                    placeholder="请输入出租周期"
                    suffix-icon="el-icon-truck"
                    v-model="updata.cycle"
                >
                </el-input>
            </div>
            <div class="conter">
                <p class="p1">价格：</p>
                <el-input
                    size="medium"
                    placeholder="请输入价格"
                    suffix-icon="el-icon-truck"
                    v-model="updata.price"
                >
                </el-input>
            </div>
            <button @click="postUpdateParking(updata)">确认修改</button>
        </div>
    </div>
</template>

<script>
import axios from "../../http/axios";
import { createNamespacedHelpers } from "vuex";
const { mapState, mapActions, mapMutations } = createNamespacedHelpers(
    "parkings"
);
export default {
    props: ["_id"],
    data() {
        return {
            updata: {
                address: "",
                number: "",
                property: "",
                cycle: "",
                price: "",
            },
        };
    },
    created() {
        console.log(this.$route.params._id);
        this.updateParkings(this.$route.params._id);
    },
    methods: {
        async updateParkings(val) {
            const { data } = await axios({
                url: "/parkings/getUpdateParking/",
                method: "post",
                data: {
                    _id: val,
                },
            });
            console.log(1111, data);
            if (data.status) {
                this.updata = data.data[0];
            }
        },
        async postUpdateParking(val) {
            console.log(val);
            const { data } = await axios({
                url: "/parkings/postUpdateParking",
                method: "post",
                data: {
                    ...val,
                },
            });
            return data;
        },
    },
};
</script>

<style  scoped>
.conter {
    width: 100%;
    height: 60px;
    display: flex;
    justify-content: center;
}
.p1 {
    width: 120px;
    margin: 0px;
    padding: 0px;
    font-size: 17px;
    line-height: 50px;
    font-weight: 500;
}
/* .container {
    display: flex;
    justify-content: space-between;
} */
.demo-input-size {
    margin: 90px auto;
}
.el-input {
    width: 400px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
}
button {
    width: 200px;
    height: 40px;
    border-radius: 20px;
    margin-left: 50px;
    background-color: #3e4b58;
    border: 0px;
    color: #e9eef3;
    outline: none;
}
</style>